package com.roocon.design_pattern.chapter08_active_object;

public class WorkingPlan extends Thread implements Plan {
  private final WorkTaskQueue workTaskQueue;

  public WorkingPlan(WorkTaskQueue workTaskQueue) {
    this.workTaskQueue = workTaskQueue;
  }

  @Override public void plan(Task task) {
    this.workTaskQueue.put(task);
  }

  @Override public void impl() {
    while (true) {
      workTaskQueue.task().execute();
    }
  }

  @Override public void run() {
    impl();
  }
}
